#include "menu.h"
#include "list.h"
/*
 int_num 输入数值并对进行选择
*/


Elenemt_data student_24072[50] =
    {
        {.age = 18, .sco = 100, .name = "唐三"},
        {.age = 18, .sco = 99, .name = "萧炎"},
        {.age = 18, .sco = 99, .name = "叶晨"},
        {.age = 18, .sco = 99, .name = "小舞"},
        {.age = 18, .sco = 99, .name = "萧熏儿"},
        {.age = 18, .sco = 99, .name = "柳如烟"},
};


void Menu_option()
{ Sql_list list;
 Sql_list * L = &list;
 Elenemt_data sql;
Init_Sql_List(L);
for (size_t i = 0; i < 6; i++)
{
   L->data[i]=student_24072[i];
}
    L->len=6;
    char name[128];
    int int_num;
    int num;
    while(1){
 printf("请选择你要进行的操作\n");
 printf("1,查成绩\n2,删除数据\n3.增加学生\n4,显示学生与成绩\n退出按0\n");
 
 scanf("%d",&int_num);
 switch (int_num)
 {
 case 1:
      printf("请输入要查询成绩的名字:\n");
      scanf("%s",name);
      num=find_by_name(L ,name);
      printf("%s的成绩为: %d\n",L->data[num].name,L->data[num].sco);
    break;
 case 2:
    printf("请输入要删除学生的姓名\n");
     scanf("%s",name);
    num=find_by_name(L ,name);  
    printf("删除了%s",L->data[num].name);
    tail_del_list(L,num);
    break;
case 3:
    printf("请输入要插入学生的姓名\n");
    scanf("%s",student_24072[L->len].name);
    printf("请输入要插入学生的成绩\n");
    scanf("%d",&student_24072[L->len].sco);
    printf("请输入要插入学生的年龄\n");
    scanf("%d",&student_24072[L->len].age);
     tail_insert_tail(L ,student_24072[L->len]);
     break;
 case 4:
    printf_Sql_List(L);
case 0:
   break;
 }
 if(int_num==0)
 break;
}
}